Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cacheable-lookup

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable-lookup

A cacheable dns.lookup(…) that respects the TTL

  • 4.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12M
increased by1.03%
Maintainers
2
Weekly downloads
 
Created

What is cacheable-lookup?

The cacheable-lookup npm package is designed to enhance the Node.js DNS module with caching capabilities. It provides a way to cache DNS lookup results in order to improve performance for repeated DNS queries. This is particularly useful for applications making numerous requests to the same domains, as it reduces the number of DNS queries that need to be performed over the network.

What are cacheable-lookup's main functionalities?

Caching DNS lookups

This feature allows you to cache DNS lookups to improve performance. The code sample demonstrates how to perform a DNS lookup for 'example.com' and cache the result.

const CacheableLookup = require('cacheable-lookup');
const cacheable = new CacheableLookup();
cacheable.lookup('example.com', (err, address, family) => {
  console.log(address);
});

Integration with http.Agent

This feature demonstrates how cacheable-lookup can be integrated with Node.js http.Agent to automatically use cached DNS lookups for HTTP requests. This can significantly reduce DNS lookup times for repeated requests to the same domain.

const CacheableLookup = require('cacheable-lookup');
const http = require('http');
const cacheable = new CacheableLookup();
const agent = new http.Agent({
  lookup: cacheable.lookup
});
http.get('http://example.com', { agent }, (res) => {
  // Handle response
});

Other packages similar to cacheable-lookup

Keywords

FAQs

Package last updated on 08 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc